//**************左侧抽屉*****************/
import 'package:flutter/material.dart';
import 'package:zapi/utils/mod.dart';

class DrawerContent extends StatefulWidget {
  const DrawerContent({Key? key}) : super(key: key);
  @override
  State<DrawerContent> createState() => _DrawerContent();
}

class _DrawerContent extends State<DrawerContent> {
  @override
  Widget build(BuildContext context) {
    return Column(children: [
      const Divider(),
      StrongText("使用说明", color: Colors.red, size: 13),
      Expanded(
        flex: 1,
        child: CardContainer(
            margin: const EdgeInsets.all(verMargin),
            padding: const EdgeInsets.all(horPadding),
            child: ListView(children: const [
              Plate(tag: "首先添加API组别：包含服务器的域名地址（不包含其他参数，可以用端口）"),
              SizedBox(height: 3),
              Plate(tag: "然后添加单个API组件：目前仅支持简单的API请求，四种组件形式：按钮，开关，滑动条，信息获取"),
              Divider(),
              Plate(tag: "长按打开菜单：可以移动组件或者组的位置，编辑或者删除。"),
            ])),
      ),
      const Divider(),
      StrongText("开发者", color: Colors.orange, size: 13),
      Expanded(
          flex: 1,
          child: CardContainer(
            margin: const EdgeInsets.all(verMargin),
            padding: const EdgeInsets.all(horPadding),
            child: ListView(children: [
              const Text("开发者信息: "),
              const Divider(),
              Wrap(crossAxisAlignment: WrapCrossAlignment.start, children: const [
                Plate(tag: "Developer: qi-xmu"),
                SizedBox(height: 3),
                Plate(tag: "邮箱:487856827@qq.com"),
              ]),
              const Divider(),
              Wrap(crossAxisAlignment: WrapCrossAlignment.start, children: const [
                Plate(tag: "Gitee: https://gitee.com/zyz-xmu/zapi.git"),
                SizedBox(height: 3),
              ]),
              const Divider(),
              Wrap(
                crossAxisAlignment: WrapCrossAlignment.start,
                children: const [Text("字体信息: "), Plate(tag: "HarmonyOS_Sans_SC_Regular")],
              ),
              const SizedBox(height: 2),
              Row(children: const [Text("应用框架: "), Plate(tag: "Flutter@3.0.0")]),
              const SizedBox(height: 2),
              Wrap(
                crossAxisAlignment: WrapCrossAlignment.start,
                children: const [Text("版本信息: "), Plate(tag: "version@1.0.0")],
              ),
              const SizedBox(height: 2),
            ]),
          )),
      const Divider(),
      StrongText("设置(待开发)", color: Colors.green, size: 13),
      Expanded(
          child: CardContainer(
        margin: const EdgeInsets.all(verMargin),
        child: ListView(children: [
          _getDrawerOption(context, '数据管理', '提供数据整理工具，云端同步，或者本地数据迁移。', Icons.backup_table, () {}),
          _getDrawerOption(context, '偏好设置', '修改默认设置，如修改字体，颜色等。', Icons.settings_outlined, () {}),
          _getDrawerOption(context, '版本信息', '版本信息，开发者信息，联系开发者。', Icons.info_outline, () {}),
        ]),
      )),
    ]);
  }
}

Widget _getDrawerOption(BuildContext context, title, subtitle, icon, onTap) => InkWell(
    onTap: onTap,
    splashColor: Colors.green,
    child: ListTile(
      dense: true,
      title: Text(title),
      subtitle: Text(subtitle, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 11)),
      leading: Icon(icon, size: 30),
    ));
